/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mti.javashare.webservices;

import com.mti.javashare.beans.User;
import java.util.Collection;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Toto
 */
@WebService
@Path("/User/")
public interface IUserWebService
{
    @GET
    @Path("/add/{username}/{pass}")
    @WebMethod(operationName = "add")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
    int add(
        @WebParam(name = "username")
        @PathParam(value="username")
        String username,
        @WebParam(name = "pass")
        @PathParam(value="pass")
        String pass);
    
    @GET
    @Path("/update/{id}/{username}/{pass}")
    @WebMethod(operationName = "update")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
    void update(
        @WebParam(name = "id")
        @PathParam(value="id")
        int id,
        @WebParam(name = "username")
        @PathParam(value="username")
        String username,
        @WebParam(name = "pass")
        @PathParam(value="pass")
        String pass);
    
    @GET
    @Path("/remove/{id}")
    @WebMethod(operationName = "remove")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
    void remove(
        @WebParam(name = "id")
        @PathParam(value="id")
        int id);

    @GET
    @Path("/getById/{id}")
    @WebMethod(operationName = "getById")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    User getById(
        @WebParam(name = "id")
        @PathParam(value="id")
        int id);
    
    @GET
    @Path("/getByName/{username}")
    @WebMethod(operationName = "getByName")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    User getByName(
        @WebParam(name = "username")
        @PathParam(value="username")
        String username);
    
    @GET
    @Path("/getAll")
    @WebMethod(operationName = "getAll")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    Collection<User> getAll();

    @GET
    @Path("/addFriend/{id1}/{id2}")
    @WebMethod(operationName = "addFriend")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
    void addFriend(
        @WebParam(name = "id1")
        @PathParam(value="id1")
        int id1,
        @WebParam(name = "id2")
        @PathParam(value="id2")
        int id2);
    
    @GET
    @Path("/removeFriend/{id1}/{id2}")
    @WebMethod(operationName = "removeFriend")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
    void removeFriend(
        @WebParam(name = "id1")
        @PathParam(value="id1")
        int id1,
        @WebParam(name = "id2")
        @PathParam(value="id2")
        int id2);

    @GET
    @Path("/getFriends/{id}")
    @WebMethod(operationName = "getFriends")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    Collection<User> getFriends(
        @WebParam(name = "id")
        @PathParam(value="id")
        int id);
}
